package com.yun.blog.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * title        : Blog
 * projectName  : dantouBlog-back
 * description  : TODO
 * author       : simple
 * date         : 2022/11/23下午8:06
 */

/*CREATE TABLE `blog`
(
    `blog_id`          int UNIQUE PRIMARY KEY NOT NULL AUTO_INCREMENT COMMENT '博客id',
    `blog_title`       varchar(200)           NOT NULL COMMENT '博客标题',
    `blog_img`         varchar(255)           NOT NULL COMMENT '博客封面url',
    `blog_content`     mediumtext             NOT NULL COMMENT '博客内容',
    `blog_category_id` int                    NOT NULL COMMENT '博客分类id',
    `blog_status`      tinyint(0)             NOT NULL DEFAULT 0 COMMENT '0-草稿 1-待审核 2-发布',
    `blog_views`       int(0)                 NOT NULL DEFAULT 0 COMMENT '阅读量',
    `enable_comment`   boolean                NOT NULL DEFAULT TRUE COMMENT '是否允许评论',
    `is_deleted`       boolean                NOT NULL DEFAULT FALSE COMMENT '是否删除',
    `create_time`      datetime(0)            NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
    `update_time`      datetime(0)            NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    FOREIGN KEY (`blog_category_id`) REFERENCES blog_category (`category_id`)

);*/
@Data
@TableName("blog")
public class Blog implements Serializable {

    @TableId(type = IdType.AUTO)
    private Integer blogId;
    private Integer authorId;

    @TableField(exist = false)
    private User author;
    private String blogTitle;
    private String blogImg;
    private String blogContent;
    private String blogAbstract;
    private Integer blogCategoryId;

    // 博客分类名称，不是数据库字段，需要额外的查询
    @TableField(exist = false)
    private String blogCategoryName;

    // 标签列表
    @TableField(exist = false)
    private List<Tag> tags;


    // 博客状态，ture发布，false草稿
    private Boolean blogStatus;

    // 浏览量
    private Integer blogViews;

    // 是否允许评论
    private Boolean enableComment;

    private Boolean isDeleted;
    private Boolean isTop;

    @JsonFormat(pattern = "yyyy年MM月dd日 hh:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @JsonFormat(pattern = "yyyy年MM月dd日 hh:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @JsonFormat(pattern = "yyyy年MM月dd日 hh:mm:ss", timezone = "GMT+8")
    private Date releaseTime;

}
